How to Get Access to K8s Clusters
Demonstrate how to connect to one or more Kubernetes clusters using one or multiple kubeconfig.yaml
files.
Cluster Access Provided by Nebul
Nebul will:
Provide the kubeconfig secret for each Kubernetes cluster you are authorized to access.
Ensure each secret contains a valid kubeconfig.yaml
file configured with the appropriate credentials and context.
Accessing the Kubernetes Cluster via Kubeconfig
Customers will be provided access to the Kubernetes cluster using a kubeconfig.yaml
secret file.
Export the kubeconfig file:
export KUBECONFIG=~/<path-to-fodler>/myconfig.yaml
Make Changes resilient to reboots
If it’s' a ZSH based Shell:
echo 'export KUBECONFIG=~/myconfig.yaml' > ~/.zshrc
if it’s' a BASH based Shell:
echo 'export KUBECONFIG=~/myconfig.yaml' > ~/.bashrc
Testing connection
kubectl get nodes
$ kubectl get nodes
NAME STATUS ROLES AGE VERSION
node1 Ready control-plane 25d v1.28.2
node2 Ready <none> 25d v1.28.2
node3 Ready <none> 25d v1.28.2
Accessing 2 or more Clusters via Kubeconfig
If you have one or more Clusters you can write the config this way, separated by “:”
echo 'export KUBECONFIG=~/myconfig1.yaml:~/myconfig2.yaml
From now on you can switch context:
kubectl config get-contexts # list available contexts
kubectl config use-context <context-name>
Recommended Way: Using kubectx to switch between Contexts
With Kubectx you can easily switch contexts without the need to write the full kubectl switch context command line.
On macOS (with Homebrew):
brew install kubectx
On Linux:
sudo git clone https://github.com/ahmetb/kubectx /opt/kubectx
sudo ln -s /opt/kubectx/kubectx /usr/local/bin/kubectx
sudo ln -s /opt/kubectx/kubens /usr/local/bin/kubens
How to use kubectx:
List all contexts:
kubectx
expected Output:
$ kubectx
dev-cluster
prod-cluster
staging-cluster
minikube
Switch to a context:
kubectx <context-name>